<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login</title>
    <script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
</head>

<body>
    <form action="" method="POST">
        <label for="">
            name <input type="text" name="name">
            password <input type="password" name="password">
            <input type="button" value="login" onclick="submit()">
        </label>
    </form>
    <script>
        function submit() {
            $.post("login", {
                name: $("input[name='name']"),
                password: $("input[name='password']"),
            },function (data) {
                console.log(data)
            },"json")
        }
    </script>
</body>

</html>